package com.example.juc;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;

public class AtomicLongTest {
    public static void main(String[] args) throws InterruptedException {
        AtomicLong num = new AtomicLong(0);
        for (int i = 0; i < 3; i++) {
            new Thread(()->{
                System.out.printf("【%s]数据的加法计算: %d %n", Thread.currentThread().getName(), num.addAndGet(100));
            }).start();
        }
        TimeUnit.SECONDS.sleep(1);
        System.out.println("【计算完   成】最终的计算结果为: " + num);
    }
}
